Skip to main content

RuleBuilder<T, TProperty>

Builds a validation rule and constructs a validator.

Assembly: ServiceStack.dll
View Source
Declaration
public class RuleBuilder<T, TProperty> : IRuleBuilderOptions<T, TProperty>, IConfigurable<PropertyRule, IRuleBuilderOptions<T, TProperty>>, IRuleBuilderInitial<T, TProperty>, IConfigurable<PropertyRule, IRuleBuilderInitial<T, TProperty>>, IRuleBuilderInitialCollection<T, TProperty>, IRuleBuilder<T, TProperty>, IConfigurable<CollectionPropertyRule<T, TProperty>, IRuleBuilderInitialCollection<T, TProperty>>

Properties

Rule

The rule being created by this RuleBuilder.

View Source
Declaration
public PropertyRule Rule { get; }

ParentValidator

Parent validator

View Source
Declaration
public IValidator<T> ParentValidator { get; }

Methods

SetValidator(IPropertyValidator)

Sets the validator associated with the rule.

View Source
Declaration
public IRuleBuilderOptions<T, TProperty> SetValidator(IPropertyValidator validator)
Returns

ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>

Parameters
TypeNameDescription
ServiceStack.FluentValidation.Validators.IPropertyValidatorvalidatorThe validator to set

|

SetValidator(IValidator<TProperty>, String[])

Sets the validator associated with the rule. Use with complex properties where an IValidator instance is already declared for the property type.

View Source
Declaration
public IRuleBuilderOptions<T, TProperty> SetValidator(IValidator<TProperty> validator, params string[] ruleSets)
Returns

ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>

Parameters
TypeNameDescription
ServiceStack.FluentValidation.IValidator<T>validatorThe validator to set

| | System.String[] | ruleSets |

|

SetValidator<TValidator>(Func<T, TValidator>, String[])

Sets the validator associated with the rule. Use with complex properties where an IValidator instance is already declared for the property type.

View Source
Declaration
public IRuleBuilderOptions<T, TProperty> SetValidator<TValidator>(Func<T, TValidator> validatorProvider, params string[] ruleSets)
where TValidator : IValidator<TProperty>
Returns

ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>

Parameters
TypeNameDescription
System.Func<<T>,<TValidator>>validatorProviderThe validator provider to set

| | System.String[] | ruleSets |

|

Type Parameters
  • TValidator

SetValidator<TValidator>(Func<T, TProperty, TValidator>, String[])

Associates a validator provider with the current property rule.

View Source
Declaration
public IRuleBuilderOptions<T, TProperty> SetValidator<TValidator>(Func<T, TProperty, TValidator> validatorProvider, params string[] ruleSets)
where TValidator : IValidator<TProperty>
Returns

ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>

Parameters
TypeNameDescription
System.Func<<T>,<TProperty>,<TValidator>>validatorProviderThe validator provider to use

| | System.String[] | ruleSets |

|

Type Parameters
  • TValidator

SetValidator<TValidator>(Func<ICommonContext, TValidator>)

Sets the validator associated with the rule. Use with complex properties where an IValidator instance is already declared for the property type.

View Source
Declaration
public IRuleBuilderOptions<T, TProperty> SetValidator<TValidator>(Func<ICommonContext, TValidator> validatorProvider)
where TValidator : IValidator<TProperty>
Returns

ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>

Parameters
TypeNameDescription
System.Func<ServiceStack.FluentValidation.ICommonContext,<TValidator>>validatorProviderThe validator provider to set

|

Type Parameters
  • TValidator

IConfigurable<PropertyRule, IRuleBuilderOptions<T, TProperty>>.Configure(Action<PropertyRule>)

View Source
Declaration
IRuleBuilderOptions<T, TProperty> IConfigurable<PropertyRule, IRuleBuilderOptions<T, TProperty>>.Configure(Action<PropertyRule> configurator)
Returns

ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>

Parameters
TypeName
System.Action<ServiceStack.FluentValidation.Internal.PropertyRule>configurator

IConfigurable<PropertyRule, IRuleBuilderInitial<T, TProperty>>.Configure(Action<PropertyRule>)

View Source
Declaration
IRuleBuilderInitial<T, TProperty> IConfigurable<PropertyRule, IRuleBuilderInitial<T, TProperty>>.Configure(Action<PropertyRule> configurator)
Returns

ServiceStack.FluentValidation.IRuleBuilderInitial<<T>,<TProperty>>

Parameters
TypeName
System.Action<ServiceStack.FluentValidation.Internal.PropertyRule>configurator

IConfigurable<CollectionPropertyRule<T, TProperty>, IRuleBuilderInitialCollection<T, TProperty>>.Configure(Action<CollectionPropertyRule<T, TProperty>>)

View Source
Declaration
IRuleBuilderInitialCollection<T, TProperty> IConfigurable<CollectionPropertyRule<T, TProperty>, IRuleBuilderInitialCollection<T, TProperty>>.Configure(Action<CollectionPropertyRule<T, TProperty>> configurator)
Returns

ServiceStack.FluentValidation.IRuleBuilderInitialCollection<<T>,<TProperty>>

Parameters
TypeName
System.Action<ServiceStack.FluentValidation.Internal.CollectionPropertyRule<<T>,<TProperty>>>configurator

Transform<TNew>(Func<TProperty, TNew>)

View Source
Declaration
[Obsolete("Use RuleFor(x => x.Property, transformer) instead. This method will be removed in FluentValidation 10.")]
public IRuleBuilderInitial<T, TNew> Transform<TNew>(Func<TProperty, TNew> transformationFunc)
Returns

ServiceStack.FluentValidation.IRuleBuilderInitial<<T>,<TNew>>

Parameters
TypeName
System.Func<<TProperty>,<TNew>>transformationFunc
Type Parameters
  • TNew

Implements

  • ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>
  • ServiceStack.FluentValidation.Internal.IConfigurable<ServiceStack.FluentValidation.Internal.PropertyRule,ServiceStack.FluentValidation.IRuleBuilderOptions<<T>,<TProperty>>>
  • ServiceStack.FluentValidation.IRuleBuilderInitial<<T>,<TProperty>>
  • ServiceStack.FluentValidation.Internal.IConfigurable<ServiceStack.FluentValidation.Internal.PropertyRule,ServiceStack.FluentValidation.IRuleBuilderInitial<<T>,<TProperty>>>
  • ServiceStack.FluentValidation.IRuleBuilderInitialCollection<<T>,<TProperty>>
  • ServiceStack.FluentValidation.IRuleBuilder<<T>,<TProperty>>
  • ServiceStack.FluentValidation.Internal.IConfigurable<ServiceStack.FluentValidation.Internal.CollectionPropertyRule<<T>,<TProperty>>,ServiceStack.FluentValidation.IRuleBuilderInitialCollection<<T>,<TProperty>>>